package com.zyh.homework.test1;

import com.alibaba.fastjson.JSON;
import org.dom4j.DocumentException;

import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

/**
 * @Author zyh
 * @Date 2024/8/13 19:47
 * @Description
 */

public class Test4 {
    public static void main(String[] args) throws IOException, DocumentException {
        FileReader fileReader = new FileReader("D:\\Code\\IDEA\\idea_projects\\JavaSE-plus\\day15-code\\src\\com\\zyh\\homework\\test1\\test.xml");
        List<Book> list = Test3.readXml(fileReader);
        String listStr = JSON.toJSONString(list);
        System.out.println("listStr = " + listStr);
        BufferedWriter bw=new BufferedWriter(new FileWriter("D:\\Code\\IDEA\\idea_projects\\JavaSE-plus\\day15-code\\src\\com\\zyh\\homework\\test1\\books.json"));
        bw.write(listStr);
        bw.flush();
        bw.close();
    }
}
